<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<script src="js/communication/ComPort.js" type="text/javascript"></script>
<script src="js/communication/SCISCommand.js" type="text/javascript"></script>
<script src="js/ElectronicScale.js" type="text/javascript"></script>
<script src="js/domain/WeightInfo.js" type="text/javascript"></script>

<script type="text/javascript">
    var flag;
    var es;
    function updateH2Thread(){
        var wi = es.weightInfo;
        //wi.printf();
        document.getElementById("showWeight").innerText = wi.showWeight;
        document.getElementById("tareWeight").innerText = wi.showTareWeight;
        document.getElementById("dit").innerText = wi.digits;
        document.getElementById("weightType").innerText = wi.showWeightType;
    }
    window.onload = function (ev) {
        //加载串口
        // es = new ElectronicScale();
        // flag = setInterval("updateH2Thread()",1000);
    }
    window.onunload = function (ev) {
        clearInterval(flag);
        es.closeDevice();
    }
    
    // function closeComm() {
    //     es.closeDevice();
    // }
    function openComm() {
        es = new ElectronicScale();
        es.openDevice();
        flag = setInterval("updateH2Thread()",100);
    }
</script>

<body>
    <input type="button" onclick="openComm()" value="打开串口">

    <h4>显示重量：</h4><h4 id="showWeight"></h4>
    <h4>皮重：</h4><h4 id="tareWeight"></h4>
    <h4>小数点：</h4><h4 id="dit"></h4>
    <h4>显示重量类型：</h4><h4 id="weightType"></h4>
</body>
</html>